home *** CD-ROM | disk | FTP | other *** search
AmigaBASIC Source Code | 1992-07-09 | 11.1 KB | 375 lines | [MSBC/MSBB] |
- REM “Casio Voice Print”
- REM For the Casio CZ 101, 1000, 3000 and 5000 synthesizers.
-
- REM This program reads voice voice files in the format of the
- REM Midimac™ Casio Patch Librarian from Opcode Systems.
- REM It displays or prints the voices in either the format
- REM of Casio’s Sound Data Book or in hexadecimal format.
- REM It requires the Chicago 12 and Monaco 9 point fonts
- REM and uses no Basic GOTO statements.
-
- REM It’s a FREE introductory program,
- REM showing MIDI music programming techniques.
- REM It is one of a series of programs and tools available from
- REM ALTECH Systems, Suite 200, 831 Kings Highway
- REM Shreveport, LA 71104; tel. (318) 226-1702
- REM In addition, the $30 MIDIBASIC™ shareware diskette includes:
- REM • MIDIBASIC.rsrc, which can be called from within a Microsoft®
- REM Basic program, giving the programmer access to Midi
- REM synthesizers and other devices for which commercial software
- REM products are unavailable.
- REM • MIDIBASIC.BAS, code routines providing the same facilities
- REM from within programs compiled under ZBASIC™, etc.
- REM • MIDIBASIC™ Casio Voice Librarian, a compiled shareware
- REM product, available on several bulletin board systems.
- REM • MIDIBASIC™ Casio Voice Editor/Librarian,
- REM in full BASIC source and compiled form.
-
- REM Copyright ©1986 by Price M. Collins
- REM 57 Raven Road, Trumbull, CT 06611
-
- DIM Voices$(32),Names$(32),x$(3),rectangle%(11)
- DEF FNtd$(j)=RIGHT$("00"+MID$(STR$(INT(j)),2),2)
- DEF FNfd$(j)=FNtd$(j)+" "
- DEF FNam(j)=ASC(MID$(d$,j,1))
- DEF FNhex2$(j)=RIGHT$("00"+HEX$(j),2)
- DEF FNpad$(d$)=LEFT$(d$+SPACE$(42),42)
- f$="" : REM contains file name; if none, then blank
- printflag=0 : REM 1=line printer output; 0=screen display
- databook=1 : REM 1=sound data format; 0=hexadecimal display
- FOR i=0 TO 11 : READ rectangle%(i) : NEXT : REM erasure dimensions
- DATA 10,345,40,512,35,0,342,512,70,0,342,512
-
- WINDOW 1,,(0,20)-(512,342),3
- <0x40,0x1d35b010> 1,2,"Sound Data Format",(3,3)-(160,17),3
- <0x40,0x1d35b010> 2,1,"Hexadecimal Format",(3,20)-(160,32),3
- <0x40,0x1d35b010> 3,2,"Display",(180,3)-(255,17),3
- <0x40,0x1d35b010> 4,1,"Print",(180,20)-(255,32),3
- GOSUB CreateButton5
-
- MENU 5,0,0,"" : MENU 4,0,0,"" : MENU 3,0,0,"" : MENU 2,0,0,"" : MENU 1,0,0,""
- MENU 1,0,1,"CASIO VOICE PRINT"
- MENU 1,1,1,"About Casio Voice Print…"
- MENU 1,2,1,"Quit"
-
- ON <0x43,0x1d35b010> GOSUB DialogCheck
- ON MENU GOSUB MenuCheck
- ON BREAK GOSUB BreakCheck
- <0x43,0x1d35b010> ON : MENU ON : BREAK ON
-
- WHILE 1 : WEND : REM permanent loop, waiting for operator actions
-
- BreakCheck: REM subroutine to defeat combined control and period keys
- RETURN
-
- MenuCheck: REM a menu item was selected
- menunumber=MENU(0)
- menuitem=MENU(1) : IF aboutflag THEN RETURN
- MENU OFF
- IF menunumber=1 THEN IF menuitem=1 THEN GOSUB About :ELSE IF menuitem=2 THEN SYSTEM
- MENU ON
- MENU
- RETURN
-
- About:
- WINDOW 2,,(12,97)-(500,332),2
- CALL <0x1e,0x1d35b010>(0) : CALL <0x1e,0x08>(4) : CALL <0x1e,0x01>(12)
- PRINT " Casio Voice Print ";
- CALL <0x13,0x1d35b010>(4) : CALL <0x13,0x08>(9)
- PRINT "for the Casio CZ 101, 1000, 3000 & 5000 synthesizers "
- CALL <0x09,0x1d35b010>(0)
- PRINT " This program reads voice voice files produced by the Midimac™ Casio Patch"
- PRINT " Librarian from Opcode Systems. It displays or prints the voices in either"
- PRINT " the format of Casio’s Sound Data Book or in hexadecimal format."
- PRINT
- PRINT " It’s a FREE introductory program, showing MIDI music programming techniques."
- PRINT " It is one of a series of programs and tools available from ALTECH Systems,"
- PRINT " Suite 200, 831 Kings Highway, Shreveport, LA 71104, tel. (318) 226-1702" : PRINT
- PRINT " In addition to this program, the $30 MIDIBASIC™ shareware diskette includes:"
- PRINT " • MIDIBASIC.rsrc, which can be called from within a Microsoft® Basic program,"
- PRINT " giving the programmer access to Midi synthesizers and other devices"
- PRINT " for which commercial software products are unavailable."
- PRINT " • MIDIBASIC.BAS, code routines providing the same facilities from within"
- PRINT " programs compiled under ZBASIC™, etc."
- PRINT " • MIDIBASIC™ Casio Voice Librarian, a compiled shareware product,"
- PRINT " available on several bulletin board systems."
- PRINT " • MIDIBASIC™ Casio Voice Editor/Librarian, in full BASIC source"
- PRINT " and compiled form, available only from ALTECH Systems." : PRINT
- PRINT " MIDI software by Price Collins and Allen Marsalis";
- <0x40,0x1d35b010> 50,1,"OK",(440,200)-(480,230),1
- REM loop until button is clicked with interrupt to DialogCheck
- aboutflag=1 : WHILE aboutflag : WEND
- RETURN
-
- DialogCheck: REM a button was pushed
- <0x43,0x1d35b010> OFF : MENU OFF
- activity=<0x43,0x1d35b010>(0)
- WHILE activity=1
- pushed=<0x43,0x1d35b010>(1)
- WHILE pushed
- <0x40,0x1d35b010> pushed,2
- IF pushed<3 THEN GOSUB SetFormat
- IF pushed=3 OR pushed=4 THEN GOSUB SetDestination
- IF pushed=5 THEN IF f$="" THEN GOSUB ReadFile :ELSE GOSUB CloseFile
- IF pushed>5 AND pushed<10 THEN GOSUB SetRange
- IF pushed=43 OR pushed=44 THEN GOSUB ShowVoices : GOSUB ShowFirstLast
- IF pushed=50 THEN GOSUB CloseAbout
- IF pushed>10 AND pushed<43 THEN GOSUB DisplayFirst
- pushed=0
- WEND
- activity=0
- WEND
- <0x43,0x1d35b010> ON : MENU ON
- RETURN
-
- CloseAbout:
- <0x40,0x1d35b010> CLOSE 50
- WINDOW CLOSE 2
- IF printflag=0 AND f$<>"" THEN pushed=first+10
- aboutflag=0
- RETURN
-
- SetFormat: REM sound data or hexadecimal button was pushed
- databook=2-pushed
- <0x40,0x1d35b010> 3-pushed,1
- IF printflag=0 AND f$<>"" THEN pushed=first+10
- RETURN
-
- SetDestination: REM display or print button was pushed
- IF printflag=pushed-3 THEN RETURN
- printflag=pushed-3
- <0x40,0x1d35b010> 7-pushed,1
- IF f$<>"" THEN GOSUB SetButtons
- RETURN
-
- SetRange: REM change to print range
- IF pushed=6 THEN IF first=last THEN BEEP :ELSE first=first+1
- IF pushed=7 THEN IF first=1 THEN BEEP :ELSE first=first-1
- IF pushed=8 THEN IF last=patches THEN BEEP :ELSE last=last+1
- IF pushed=9 THEN IF last=first THEN BEEP :ELSE last=last-1
- GOSUB ShowFirstLast
- <0x40,0x1d35b010> pushed,1
- RETURN
-
- ReadFile: REM select, open, read, close a data file; then display first voice
- f$=FILES$(1,"MPD5MPD1")
- REM file types for CZ-101 and 5000, respectively
- IF f$="" THEN RETURN
- OPEN "R",1,f$,146 : FIELD 1,146 AS C$
- d$="" : GET 1 : d$=d$+C$
- patches=FNam(2) : REM get number of patches, 16 or 32
- FOR i=2 TO patches : GET 1 : d$=d$+C$ : NEXT
- GET 1 : d$=d$+LEFT$(C$,2)
- CLOSE 1
- FOR i=1 TO patches : REM load the two main data arrays
- j=146*(i-1)
- Names$(i)=MID$(d$,j+4,FNam(j+3))
- Voices$(i)=MID$(d$,j+21,128)
- NEXT
- FOR i=LEN(f$) TO 1 STEP -1 : REM eliminate leading volumes/folders
- IF MID$(f$,i,1)=":" THEN f$=MID$(f$,i+1) :ELSE NEXT i
- GOSUB EraseButton5 : REM create new button for file closure
- <0x40,0x1d35b010> 5,1,"Close File",(270,10)-(340,25),1
- CALL <0x0e,0x1d35b010>(345,22)
- CALL <0x1e,0x1d35b010>(0) : CALL <0x1e,0x08>(0) : CALL <0x1e,0x01>(12)
- PRINT f$; : REM display file name
- GOSUB SetButtons
- RETURN
-
- CloseFile:
- f$="" : GOSUB EraseButton5 : GOSUB ErasePrintButtons
- GOSUB CreateButton5
- RETURN
-
- SetButtons:
- GOSUB ErasePrintButtons
- first=1
- IF printflag THEN last=patches : GOSUB CreatePrintButtons :ELSE last=1 : GOSUB CreateDisplayButtons
- RETURN
-
- CreateButton5:
- <0x40,0x1d35b010> 5,2,"Open File",(270,10)-(340,25),1
- RETURN
-
- CreatePrintButtons: REM display buttons for printing a file
- <0x40,0x1d35b010> 6,1,"Up",(202,90)-(240,103),3
- <0x40,0x1d35b010> 7,1,"Down",(202,120)-(260,133),3
- <0x40,0x1d35b010> 8,1,"Up",(280,90)-(320,103),3
- <0x40,0x1d35b010> 9,1,"Down",(280,120)-(340,133),3
- <0x40,0x1d35b010> 43,1,"Print",(10,95)-(100,108),1
- <0x40,0x1d35b010> 44,1,"Print to Disk",(10,115)-(100,128),1
- GOSUB ShowFirstLast
- RETURN
-
- ShowFirstLast:
- CALL <0x1d,0x1d35b010>(4) : CALL <0x1d,0x08>(0) : CALL <0x1d,0x01>(9)
- CALL <0x3e,0x1d35b010>(168,115) : PRINT "From: ";FNtd$(first);" To: ";FNtd$(last)
- RETURN
-
- CreateDisplayButtons: REM voice buttons for selecting screen displays
- CALL <0x1d,0x1d35b010>(4) : CALL <0x1d,0x08>(0) : CALL <0x1d,0x01>(9)
- FOR i=0 TO 15
- CALL <0x14,0x1d35b010>(31*i+13,47)
- PRINT i+1
- <0x40,0x1d35b010> i+11,1,"",(31*i+3,37)-(31*i+17,49),2
- NEXT
- DisplayFirstEnd=(patches=32)
- WHILE DisplayFirstEnd : REM 16 extra buttons for CZ 3000/5000 files
- FOR i=0 TO 15
- CALL <0x14,0x1d35b010>(31*i+13,64)
- PRINT i+17
- <0x40,0x1d35b010> i+27,1,"",(31*i+3,54)-(31*i+17,66),2
- NEXT
- DisplayFirstEnd=0
- WEND
- IF printflag=0 THEN pushed=first+10 : <0x40,0x02> pushed,2
- RETURN
-
- EraseButton5:
- <0x40,0x1d35b010> CLOSE 5
- CALL <0x13,0x1d35b010>(VARPTR(rectangle%(0)))
- RETURN
-
- ErasePrintButtons:
- FOR i=6 TO 44
- <0x40,0x1d35b010> CLOSE i
- NEXT
- CALL <0x13,0x1d35b010>(VARPTR(rectangle%(4)))
- RETURN
-
- DisplayFirst:
- <0x40,0x1d35b010> first+10,1
- <0x40,0x1d35b010> pushed,2
- first=pushed-10
- last=pushed-10
- GOSUB ShowVoices
- RETURN
-
- ShowVoices:
- IF pushed<43 THEN OPEN "O",2,"SCRN:"
- IF pushed=43 THEN OPEN "O",2,"LPT1:DIRECT"
- IF pushed=44 THEN temp$=FILES$(0,"Output File Name:") : IF temp$="" THEN RETURN :ELSE OPEN "O",2,temp$,512
- FOR voice=first TO last
- IF printflag=0 THEN CALL <0x1d,0x1d35b010>(VARPTR(rectangle%(8)))
- CALL <0x0c,0x1d35b010>(1,79)
- IF printflag THEN printline$="File: "+f$+" Tone #"+STR$(voice)+": " :ELSE printline$=""
- CALL <0x1d,0x1d35b010>(4) : CALL <0x1d,0x08>(1) : CALL <0x1d,0x01>(9)
- printline$=printline$+Names$(voice)
- LineOut(printline$)
- IF printflag<>0 OR databook=0 THEN LineOut("")
- d$=Voices$(voice)
- CALL <0x13,0x1d35b010>(4) : CALL <0x13,0x08>(9)
- IF databook THEN GOSUB SoundData :ELSE GOSUB HexPrint
- IF pushed=43 THEN LineOut(CHR$(12))
- IF pushed=44 THEN LineOut(STRING$(10,13))
- NEXT voice
- CLOSE 2
- RETURN
-
- HexPrint: REM display or print a patch in hexadecimal format
- CALL <0x09,0x1d35b010>(0)
- FOR i=0 TO 112 STEP 16
- printline$="00"+FNhex2$(i)+": "
- FOR j=1 TO 15 STEP 2
- printline$=printline$+FNhex2$(FNam(i+j))+FNhex2$(FNam(i+j+1))+" "
- NEXT
- LineOut(printline$)
- NEXT
- RETURN
-
- SoundData: REM display or print a patch in sound data book format
- CALL <0x09,0x1d35b010>(4)
- PRINT #2,SPC(12-3*(pushed<43));"Modulation";SPC(2);" Detune ";SPC(2);" Vibrato ";SPC(2);" Octave "
- CALL <0x09,0x1d35b010>(0)
- IF printflag THEN LineOut(" __________ ____________________ _____________________ _________")
- LineOut("LineSelect Ring Noise +/- Octave Note Fine Wave Delay Rate Depth +/- Range")
- pflag=FNam(1) AND 15
- pflag3=pflag AND 3
- printline$=" "+MID$(" 1 2 1+1'1+2'",1+4*pflag3,4)+" "
- FOR j=8 TO 4 STEP -4
- printline$=printline$+MID$("OFF ON ",1+(FNam(16) AND 4*j)/j,3)+" "
- NEXT
- printline$=printline$+" "+MID$("+-",1+(FNam(2) AND 1),1)+" "
- j=FNam(4)
- k=FNam(3)/4
- printline$=printline$+FNtd$(j\12)+" "+FNtd$(j MOD 12)+" "+FNtd$(k-(k\16))+" "
- j=FNam(5) AND 46
- IF j=32 THEN printline$=printline$+"3" :ELSE printline$=printline$+MID$(" 4 2 1",j,1)
- FOR j=6 TO 12 STEP 3
- printline$=printline$+" "+FNtd$(FNam(j))
- NEXT
- printline$=printline$+" "
- IF pflag>7 THEN printline$=printline$+"- 1" :ELSE IF pflag>3 THEN printline$=printline$+"+ 1" :ELSE printline$=printline$+" 0"
- LineOut(printline$)
- pflag3=pflag3 MOD 2
- FOR h=56 TO 22 STEP -17
- LineOut("")
- printline$=""
- FOR i=1 TO 1+pflag3
- IF h=22 THEN printline$=printline$+"DCA"+STR$(i)+", Key Follow="+STR$(FNam(57*i-40))
- IF h=39 THEN printline$=printline$+"DCW"+STR$(i)+", Key Follow="+STR$(FNam(57*i-38))
- hEquals56=(h=56)
- WHILE hEquals56
- j=57*i-42
- printline$=printline$+"DCO"+STR$(i)+", Wave Forms: 1st="
- m=(FNam(j) AND 224)\32
- n=(FNam(j+1) AND 192)\64
- IF m<4 THEN m=m+1 :ELSE IF m>5 THEN m=m+n-1
- printline$=printline$+MID$(STR$(m),2)+", 2nd="
- m=(FNam(j) AND 28)\4
- IF m>5 THEN m=m+n-1
- printline$=printline$+MID$(STR$(m),2)
- hEquals56=0
- WEND
- IF i=1 THEN printline$=FNpad$(printline$)
- NEXT i
- LineOut(printline$)
- IF printflag THEN LineOut("")
- printline$=MID$("Amp Wave Pitch ",1+6*(h-22)/17,6)
- FOR i=1 TO 8
- printline$=printline$+STR$(i)+" "
- NEXT
- IF pflag3 THEN printline$=FNpad$(printline$)+printline$
- LineOut(printline$)
- FOR i=1 TO 3
- x$(i)=""
- NEXT
- FOR i=h TO h+57*pflag3 STEP 57
- x$(1)=x$(1)+"Rate "
- x$(2)=x$(2)+"Level "
- x$(3)=x$(3)+" "
- FOR j=i+0 TO i+14 STEP 2
- m=FNam(j) AND 127
- IF h=39 THEN m=m-8
- IF h<56 THEN IF m=0 THEN n=0 :ELSE IF m=119 THEN n=99 :ELSE n=99*m/119+1
- IF h=56 THEN IF m=0 THEN n=0 :ELSE IF m=127 THEN n=99 :ELSE n=99*m/127+1
- x$(1)=x$(1)+FNfd$(n)
- m=FNam(j+1) AND 127
- n=m
- IF h=22 AND m>0 THEN n=m-28
- IF h=39 AND m>0 THEN IF m=127 THEN n=99 :ELSE n=99*m/127+1
- IF h=56 AND m>63 THEN n=n-4
- x$(2)=x$(2)+FNfd$(n)
- IF (FNam(j+1) AND 128) THEN temp$=" sus" :ELSE temp$=" "
- IF j=i+2*FNam(i-1) THEN temp$=" end" : j=i+15 : REM force end
- x$(3)=x$(3)+temp$
- NEXT j
- IF i<79 THEN FOR j=1 TO 3 : x$(j)=FNpad$(x$(j)) : NEXT
- NEXT i
- FOR i=1 TO 3
- LineOut(x$(i))
- NEXT
- NEXT h
- RETURN
-
- SUB LineOut(printline$) STATIC
- SHARED pushed
- REM remove trailing blanks for clean print files
- WHILE RIGHT$(printline$,1)=" "
- printline$=LEFT$(printline$,LEN(printline$)-1)
- WEND
- REM print three leading blanks, if on screen
- PRINT #2,SPC(-3*(pushed<43));printline$
- END SUB
-
-